package com.siwei.mes.entity.erp;

import com.siwei.mes.common.util.JsonUtils;
import com.siwei.mes.entity.dto.PhbhistoryPhbDto;
import com.siwei.mes.entity.dto.PhbhistoryPhbInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * ERP配合比修改记录(Phbhistory)实体类
 *
 * @author linzi
 * @since 2024-09-05 21:37:19
 */
@Data
@Accessors(chain = true)
@Table(name = "phbhistory")
@ApiModel(value = "Phbhistory", description = "ERP配合比修改记录")
public class Phbhistory implements Serializable {
    private static final long serialVersionUID = 853912052567116649L;
    /**
     * 配合比历史记录id
     */
    @Column(name = "PHID")
    @ApiModelProperty(value = "配合比历史记录id", name = "phid")
    private Integer phid;
    /**
     * 任务单号
     */
    @Column(name = "rwdh")
    @ApiModelProperty(value = "任务单号", name = "rwdh")
    private Integer rwdh;
    /**
     * 修改前配合比
     */
    @Column(name = "beforePhb")
    @ApiModelProperty(value = "修改前配合比", name = "beforephb")
    private String beforephb;
    /**
     * 修改后配合比
     */
    @Column(name = "afterPhb")
    @ApiModelProperty(value = "修改后配合比", name = "afterphb")
    private String afterphb;
    @Column(name = "URID")
    @ApiModelProperty(value = "${column.comment}", name = "urid")
    private Integer urid;
    /**
     * 之前配合比号
     */
    @Column(name = "beforePhbh")
    @ApiModelProperty(value = "之前配合比号", name = "beforephbh")
    private Integer beforephbh;
    /**
     * 之后配合比号
     */
    @Column(name = "afterPhbh")
    @ApiModelProperty(value = "之后配合比号", name = "afterphbh")
    private Integer afterphbh;
    @Column(name = "PBID")
    @ApiModelProperty(value = "${column.comment}", name = "pbid")
    private Integer pbid;
    /**
     * trwdphb的主键
     */
    @Column(name = "FId")
    @ApiModelProperty(value = "trwdphb的主键", name = "fid")
    private Integer fid;
    /**
     * 创建时间
     */
    @Column(name = "createTime")
    @ApiModelProperty(value = "创建时间", name = "createtime")
    private Date createtime;
    /**
     * 0 施工配比 1 砂浆配比
     */
    @Column(name = "phbType")
    @ApiModelProperty(value = "0 施工配比 1 砂浆配比", name = "phbtype")
    private Integer phbtype;
    @Column(name = "mixtable")
    @ApiModelProperty(value = "${column.comment}", name = "mixtable")
    private String mixtable;

    @Transient
    @ApiModelProperty(value = "修改前配合比信息")
    private List<PhbhistoryPhbInfo> beforePhbList;

    @Transient
    @ApiModelProperty(value = "修改后配合比信息")
    private List<PhbhistoryPhbInfo> afterPhbList;

    @Transient
    @ApiModelProperty(value = "修改后配合比信息(打印相关数据)")
    private List<PhbhistoryPhbDto> afterPhbDtoList;

    @Transient
    @ApiModelProperty(value = "调整时间")
    private Date tzsj;

    /**
     * json转对象
     *
     * @param str
     * @return
     */
    public static List<PhbhistoryPhbInfo> jsonToObjList(String str) {
        if (StringUtils.isBlank(str)) {
            return null;
        }
        String info = StringEscapeUtils.unescapeJava(str);
        return JsonUtils.jsonToList(info, PhbhistoryPhbInfo.class);
    }
}
